import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '客户编码',
    align:"center",
    dataIndex: 'customerCode',
   },
   {
    title: '客户名称',
    align:"center",
    dataIndex: 'customerName'
   },
   {
    title: '客户等级',
    align:"center",
    dataIndex: 'customerLevel_dictText'
   },
   {
    title: '联系人名称',
    align:"center",
    dataIndex: 'contactName'
   },
   {
    title: '联系人手机号',
    align:"center",
    dataIndex: 'contactPhone'
   },
   {
    title: '是否账期客户',
    align:"center",
    dataIndex: 'isCredit_dictText'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "客户编码",
      field: 'customerCode',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "客户名称",
      field: 'customerName',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "客户等级",
      field: 'customerLevel',
      component: 'JSelectMultiple',
      componentProps:{
          dictCode:"xlcustomerlevel"
      },
      //colProps: {span: 6},
 	},
	{
      label: "联系人名称",
      field: 'contactName',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "联系人手机号",
      field: 'contactPhone',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "是否账期客户",
      field: 'isCredit',
      component: 'JSelectMultiple',
      componentProps:{
          dictCode:"yn"
      },
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '客户编码',
    field: 'customerCode',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false, message: '请输入客户编码!'},
          ];
     },
    dynamicDisabled:true
  },
  {
    label: '客户名称',
    field: 'customerName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入客户名称!'},
          ];
     },
  },
  {
    label: '客户等级',
    field: 'customerLevel',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"xlcustomerlevel",
        type: "radio"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入客户等级!'},
          ];
     },
  },
  {
    label: '联系人名称',
    field: 'contactName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入联系人名称!'},
          ];
     },
  },
  {
    label: '联系人手机号',
    field: 'contactPhone',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入联系人手机号!',  pattern: /^1[3456789]\d{9}$/ }
          ];
     },
  },
  {
    label: '是否账期客户',
    field: 'isCredit',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"yn",
        type: "radio"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入是否账期客户!'},
          ];
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  customerCode: {title: '客户编码',order: 0,view: 'text', type: 'string',},
  customerName: {title: '客户名称',order: 1,view: 'text', type: 'string',},
  customerLevel: {title: '客户等级',order: 2,view: 'radio', type: 'string',dictCode: 'xlcustomerlevel',},
  contactName: {title: '联系人名称',order: 3,view: 'text', type: 'string',},
  contactPhone: {title: '联系人手机号',order: 4,view: 'text', type: 'string',},
  isCredit: {title: '是否账期客户',order: 5,view: 'number', type: 'number',dictCode: 'yn',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}